﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Collections;

namespace Catering
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            string[] strWeek = new string[] { "星期一(Mon)", " 星期二(Tue)", "星期三(Wed)", "星期四(Thu)", " 星期五(Fri)", "星期六(sat)", "星期日(sun)" };
            string[] canbie = new string[] { "早餐", " 午餐", "晚餐", "夜餐" };
            Application["canbie"] = canbie;
            Application["strWeek"] = strWeek;

            Hashtable ht = new Hashtable();
            Application["UsersCount"] = ht;
        }

        protected void Session_Start(object sender, EventArgs e)
        {
            //Session["GroupID"] = "1";
            //Session["ClassID"] = "1";
            //Session["User"] = "weiqi";
            //Session["UserID"] = "1";
            //Session["RoleID"] = "1";
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {
            Hashtable ht = (Hashtable)Application["UsersCount"];
            foreach (DictionaryEntry item in ht)
            {
                string[] temp = item.Value.ToString().Split(',');
                if (temp.Length > 1)
                {
                    DateTime tempdate = DateTime.Parse(temp[1]);
                    if (tempdate.AddMinutes(10) < DateTime.Now)
                    {
                        ht.Remove(item.Key);
                    }
                }
                else
                {
                    ht.Remove(item.Key);
                }
            }

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}